<?php
include ('genericos/header.php');
include ('genericos/translate.php');
?>

<link rel="stylesheet" href="css/colorbox.css" type="text/css" media="screen" title="no title" charset="utf-8">
<script src="js/jquery.colorbox.js"></script>

<!--<script language="JavaScript" type="text/javascript" src="js/jquery-1.4.4.js"></script>-->
<script language="JavaScript" type="text/javascript" src="js/ajax.js"></script>
<link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css"/>
<script src="js/languages/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8" >        </script>
<script src="js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"> </script>

<script src="js/jquery.colorbox.js"></script>
<script>
    
    function buscarPersona(){  
        var divResultado = document.getElementById('resultado');
        divResultado.innerHTML = "<img src='images/loading1.gif' />";
        var id = document.getElementById('txtId').value;
        var url = "ClassPersona.php";
        var accion = "buscar";
        var datos = url+"?ID_PERSONA="+id+"&accion="+accion;
        try {
            var Persona = new Object();
            Persona = Consultar(datos);
            Limpiar();
            if (typeof Persona.ID === "undefined"){
                divResultado.innerHTML = "<p>Persona no encontrada</p>";
            } else {
                document.getElementById('txtId').value = Persona.ID;
                document.getElementById('txtNombre').value = Persona.NOMBRE;
                divResultado.innerHTML = "";
            }
        } catch(e) { 
            alert(e.description); 
        } 
    }
    function Limpiar(){
        document.getElementById('txtId').value = "";
        document.getElementById('txtNombre').value = "";
    }
</script>

<style>
    .ui-button { margin-left: -1px; }
    .ui-button-icon-only .ui-button-text { padding: 0.35em; } 
    .ui-autocomplete-input { margin: 0; padding: 0.48em 0 0.47em 0.45em; }
</style>

<script>
    var S = jQuery.noConflict();
    (function( $ ) {
        S.widget( "ui.combobox", {
            _create: function() {
                var self = this,
                select = this.element.hide(),
                selected = select.children( ":selected" ),
                value = selected.val() ? selected.text() : "";
                var input = this.input = S( "<input>" )
                .insertAfter( select )
                .val( value )
                .autocomplete({
                    delay: 0,
                    minLength: 0,
                    source: function( request, response ) {
                        var matcher = new RegExp( S.ui.autocomplete.escapeRegex(request.term), "i" );
                        response( select.children( "option" ).map(function() {
                            var text = S( this ).text();
                            if ( this.value && ( !request.term || matcher.test(text) ) )
                                return {
                                    label: text.replace(
                                    new RegExp(
                                    "(?![^&;]+;)(?!<[^<>]*)(" +
                                        S.ui.autocomplete.escapeRegex(request.term) +
                                        ")(?![^<>]*>)(?![^&;]+;)", "gi"
                                ), "<strong>$1</strong>" ),
                                    value: text,
                                    option: this
                                };
                        }) );
                    },
                    select: function( event, ui ) {
                        ui.item.option.selected = true;
                        self._trigger( "selected", event, {
                            item: ui.item.option
                        });
                    },
                    change: function( event, ui ) {
                        if ( !ui.item ) {
                            var matcher = new RegExp( "^" + S.ui.autocomplete.escapeRegex( S(this).val() ) + "S", "i" ),
                            valid = false;
                            select.children( "option" ).each(function() {
                                if ( S( this ).text().match( matcher ) ) {
                                    this.selected = valid = true;
                                    return false;
                                }
                            });
                            if ( !valid ) {
                                // remove invalid value, as it didn't match anything
                                S( this ).val( "" );
                                select.val( "" );
                                input.data( "autocomplete" ).term = "";
                                return false;
                            }
                        }
                    }
                })
                .addClass( "ui-widget ui-widget-content ui-corner-left" );

                input.data( "autocomplete" )._renderItem = function( ul, item ) {
                    return $( "<li></li>" )
                    .data( "item.autocomplete", item )
                    .append( "<a>" + item.label + "</a>" )
                    .appendTo( ul );
                };

                this.button = $( "<button type='button'>&nbsp;</button>" )
                .attr( "tabIndex", -1 )
                .attr( "title", "Show All Items" )
                .insertAfter( input )
                .button({
                    icons: {
                        primary: "ui-icon-triangle-1-s"
                    },
                    text: false
                })
                .removeClass( "ui-corner-all" )
                .addClass( "ui-corner-right ui-button-icon" )
                .click(function() {
                    // close if already visible
                    if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
                        input.autocomplete( "close" );
                        return;
                    }

                    // work around a bug (likely same cause as #5265)
                    S( this ).blur();

                    // pass empty string as value to search for, displaying all results
                    input.autocomplete( "search", "" );
                    input.focus();
                });
            },

            destroy: function() {
                this.input.remove();
                this.button.remove();
                this.element.show();
                S.Widget.prototype.destroy.call( this );
            }
        });
    })( jQuery );

    S(function() {
        S( "#combobox" ).combobox();
        S( "#toggle" ).click(function() {
            h( "#combobox" ).toggle();
        });
    });
</script>

</head>

<body>
    <div id="wrapper">
        <script type="text/javascript">
            var z = jQuery.noConflict();
            z(document).ready(function() {
                  
                z(".topMenuAction").click( function() {
                    if (z("#openCloseIdentifier").is(":hidden")) {
                        z("#slider").animate({ 
                            marginTop: "-141px"
                        }, 500 );
                        z("#topMenuImage").html('<?php echo $_SESSION['Nombre']; ?>');
                        z("#openCloseIdentifier").show();
                    } else {
                        z("#slider").animate({ 
                            marginTop: "0px"
                        }, 500 );
                        z("#topMenuImage").html('<?php echo $_SESSION['Nombre']; ?>');
                        z("#openCloseIdentifier").hide();
                    }
                });  
            });
        </script>
        <div id="head">

            <div id="logo">

            </div>
            <div id="logout">
                <!--<a href="#" title="Mi Cuenta" alt="Mi Cuenta">Cuenta</a>-->
                <?php include ('genericos/html_logout.php'); ?>

            </div>

        </div> <!-- head -->

        <div id="Menu_principal">
            <?php include ('genericos/Menu_principal.php'); ?>
        </div> <!-- block1 -->

        <div id="block_izq">
            <form name="consulta" action="" onsubmit="buscarPersona(); return false">
                <label>ID: </label><input type="TEXT" id="txtId" name="txtId" maxlength="9" size="10" /><br />
                <label>Nombre: </label><input type="TEXT" id="txtNombre" name="txtNombre" maxlength="9" size="10" />
                <br />
                <input type="submit" value="Consultar" />
            </form>
            <div id="resultado"></div>
        </div> <!-- block3 -->
        <div id="block_der">
            <?php
            if (isset($_SESSION['Nombre'])) {
                echo $_SESSION['Nombre'] . " ";
                echo $_SESSION['idioma'] . " ";
                echo $_SESSION['IdUsuario'] . " ";
            }
            echo "<br />";
            echo $obj->property; // prints 'value'
            ?>
        </div> <!-- block4 -->

        <div id="footer">
            <?php include ('genericos/footer.php'); ?>
        </div> <!-- block5 -->

    </div> <!-- wrapper -->

</body>
</html>
